package middleware

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"github.com/gin-gonic/contrib/sessions"
	"fmt"
)

func AuthConsole() gin.HandlerFunc  {
	return func(c *gin.Context) {
		session := sessions.Default(c)
		user_id := session.Get("user_id")
		fmt.Println(user_id)
		if user_id != nil {
			c.Next()
		} else {
			c.Redirect(http.StatusMovedPermanently, "login")
			return
		}
	}
}